package com.gitee.feizns.quickstart.spring.boot.autoconfigure;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.SpringApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.lang.NonNull;

/**
 * spring boot工具类
 * @author feizns
 * @since 2025/8/14
 */
public class SpringBoots implements ApplicationListener<SpringApplicationEvent> {

    /**
     * 春季应用活动
     */
    private static SpringApplicationEvent springApplicationEvent;

    /**
     * 应用
     * @return {@link SpringApplication }
     */
    public static SpringApplication app() {
        return springApplicationEvent.getSpringApplication();
    }

    /**
     * 参数
     * @return {@link String[] }
     */
    public static String[] args() {
        return springApplicationEvent.getArgs();
    }

    @Override
    public void onApplicationEvent(@NonNull SpringApplicationEvent event) {
        springApplicationEvent = event;
    }

}
